<template>
  <div class="equipment-history">
    <div class="filter">
      <el-checkbox-group v-model="query.loss">
        <el-checkbox v-for="(item, index) in loss" :key="index" :label="index">{{ item }}</el-checkbox>
      </el-checkbox-group>
    </div>
    <el-table :data="list">
      <el-table-column label="创建时间日期" prop="create_time" />
      <el-table-column label="优先程度" prop="priority">
        <template v-slot="{row}">{{ priority[row.priority] }}</template>
      </el-table-column>
      <el-table-column label="类别" prop="category">
        <template v-slot="{row}">{{ category[row.category] }}</template>
      </el-table-column>
      <el-table-column label="专业" prop="profession">
        <template v-slot="{row}">{{ profession[row.profession] }}</template>
      </el-table-column>
      <el-table-column label="名称" prop="name" />
      <el-table-column label="生产损失" prop="loss">
        <template v-slot="{row}">{{ loss[row.loss] }}</template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { loss, profession, priority, category } from '../../../utils/options'
import API from '../../../api/maintain/wordorder'
export default {
  name: 'EquipmentHistory',
  props: {
    value: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      checked: '',
      list: [],
      loss,
      profession,
      priority,
      category,
      query: {
        loss: []
      }
    }
  },
  watch: {
    value() {
      this.index()
    },
    query: {
      deep: true,
      handler() {
        this.index()
      }
    }
  },
  created() {
    this.index()
  },
  methods: {
    index() {
      this.query.equipment_id = this.value
      API.index(this.query).then(response => {
        this.list = response.data.data
      })
    }
  }
}
</script>
